class debug(object):
    import datetime
    """Generic bug handler"""

    def __init__(self,error_type="generic",debug_level=0):
        ##will record to "error_generic.txt" unless error_type is specified
        self.type=error_type
        self.level=debug_level
        self.now = self.datetime.datetime.now()
        
        
    def bug(self,message,urgency=0):
        if urgency <= self.level:
            filename=str(self.type)+"_log"
            self.record(filename,"["+str(urgency)+"] "+str(self.now.strftime("%d-%m-%Y AT %H:%M:%S \t \t"))+str(message))
            print "record successful:  recorded to\t",filename+".txt"
            print message
            return
        
    def record_del(self,filename):
        """Empties the error log"""
        name=str(filename)+".txt"
        with open(name,"w") as write_data:
            write_data.write("")
        
    def record(self,filename,string):
        """Appends to the error log"""
        name="../debug log/"+str(filename)+".txt"
        with open(name,"a") as write_data:
            write_data.writelines(str(string)+"\n")
